﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace SplenetiX
{
    [Serializable]
    public class Projectile : Sprite
    {
        float positionStart, distance;
        int direction;

        public float Distance { get { return distance; } }

        // -- Constructeur
        public Projectile()
            : base(new Vector2(0, 0))
        { }

        public Projectile(Vector2 position, int direction)
            : base(position)
        {
            texture = Constant.SpriteProj;
            this.direction = direction;
            positionStart = position.X;
            rectangle = new Rectangle((int)position.X, (int)position.Y, texture.Width, texture.Height);
        }

        public void Update(GameTime gameTime)
        {
            position.X += direction * Constant.ProjectileVelocity * gameTime.ElapsedGameTime.Milliseconds;
            rectangle.X = (int)position.X;
            distance = Math.Abs(positionStart - position.X);
        }
    }
}
